<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册</title>
<link href="script/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">
<link type="text/css" rel="stylesheet" href="script/css/header.css">
<link type="text/css" rel="stylesheet" href="script/css/register.css">
<script src="script/bootstrap/js/jquery-1.8.2.js"></script>
<script src="script/bootstrap/js/bootstrap.js"></script>
</head>
<body>
	<div id="header">
		<div class="container">
			<ul class="nav nav-pills pull-right tnav-menu" style="margin:18px auto;">
				<li><a href="login.html">登录</a></li>
				<li><a href="advice.html">给我们提建议</a></li>
			</ul>
			<h1>
				<a title="糊涂账" href="login.html"> 
					<img width="154" height="49" src="script/img/logo3.png" title="糊涂账" alt="一起来记流水帐">
					</img>
				</a>
			</h1>
		</div>
	</div>
	<div id="main">
		<div class="container">
			<div class="row">
			<div class="span7">
				<form class="form-horizontal" id="regForm">
            		<fieldset>
            			<legend>免费注册糊涂账帐号</legend>
            			<div id="inputEmailCG" class="control-group">
            				<label class="control-label" for="inputEmail">注册邮箱</label>
            				<div class="controls">
								<input type="text" id="inputEmail" name="email" placeholder="请输入邮箱"><span id="inputEmailErrMsg" class="help-inline tRegFormInputSpan"></span>
							</div>
            			</div>
            			<div id="inputPasswordCG" class="control-group">
            				<label class="control-label" for="inputPassword">创建密码</label>
            				<div class="controls">
								<input type="password" id="inputPassword" name="password" placeholder="请输入密码"><span id="inputPasswordErrMsg" class="help-inline tRegFormInputSpan"></span>
							</div>
            			</div>
						<div class="control-group">
            				<label class="control-label" for="inputNickname">昵称</label>
            				<div class="controls">
								<input type="text" id="inputNickname" name="nickname" placeholder="请输入昵称"><span id="inputNicknameErrMsg" class="help-inline tRegFormInputSpan"></span>
							</div>
            			</div>
            			<div class="control-group">
            				<label class="control-label" for="inputSex">性别</label>
            				<div class="controls">
								<label class="radio inline">
									<input type="radio" name="sex" id="man" value="0"></input>
									男
								</label>
								<label class="radio inline">
									<input type="radio" name="sex" id="female" value="1"></input>
									女
								</label>
							</div>
            			</div>
            			<div class="control-group">
            				<label class="control-label" for="inputCity">所在城市</label>
            				<div class="controls">
								<input type="text" id="inputCity" name="city" placeholder="请输入所在城市">
							</div>
            			</div>
            			<div class="control-group">
            				<label class="control-label" for="inputDeclaration">理财宣言</label>
            				<div class="controls">
								<textarea name="declaration" rows="4" placeholder="请输入理财宣言"></textarea>
							</div>
            			</div>
            			<div class="control-group">
            				<div class="controls">
								<img src="Kaptcha.jpg" id="kaptchaImage"></img><input id="vertifyBtn" type="button" class="btn btn-link" style="font-size:13px;" value="看不清换一张？">
							</div>
            			</div>
            			<div class="control-group">
            				<label class="control-label" for="inputKaptcha">验证码</label>
            				<div class="controls">
								<input type="text" id="inputKaptcha" name="vertifycode" placeholder="请输入验证码">
							</div>
            			</div>
            			<div class="control-group">
            				<div class="controls">
            					<input id="regBtn" type="button" class="btn btn-success" style="width:220px;height: 30px;" value="注  册">
            				</div>
            			</div>
            		</fieldset>		         	
                </form>
            </div>
            </div>
		</div>
	</div>
</body>
</html>

<script type="text/javascript">
$(document).ready(function(){
	//更换验证码
	$("#vertifyBtn").click(function(){
		$("#kaptchaImage").attr('src', 'Kaptcha.jpg?' + Math.floor(Math.random()*100) );
	});
	
	$("#regBtn").click(function(){
		$.ajax({
			type: "POST",
			url: "RegUser",
			data: $("#regForm").serialize(),
			dataType: "json",
			success: function(data, textStatus) {
				if(data.success == true) {
					alert("注册成功！");
					window.location.href="login.html";
				} else {
					alert(data.msg);
					$("#kaptchaImage").attr('src', 'Kaptcha.jpg?' + Math.floor(Math.random()*100) );
					$("#inputKaptcha").val("");
				}
			}
		});
	});
});
</script>
